Class HCC.DT.HCC2HL72.TransUpdRequst Extends Ens.DataTransformDTL [ DependsOn = (EnsLib.EDI.XML.Document, EnsLib.HL7.Message) ]
{

Parameter IGNOREMISSINGSOURCE = 1;

Parameter REPORTERRORS = 1;

Parameter TREATEMPTYREPEATINGFIELDASNULL = 0;

XData DTL [ XMLNamespace = "http://www.intersystems.com/dtl" ]
{
<transform sourceClass='EnsLib.EDI.XML.Document' targetClass='EnsLib.HL7.Message' sourceDocType='PRPA_IN302012UV:PRPA_IN302012UV' targetDocType='2.5.1:ADT_A01' create='new' language='objectscript' >
<assign value='source.{id().extension}' property='target.{MSH:MessageControlID}' action='set' />
<assign value='source.{creationTime().value}' property='target.{MSH:DateTimeOfMessage.Time}' action='set' />
<assign value='"ADT"' property='target.{MSH:MessageType.MessageCode}' action='set' />
<assign value='"A02"' property='target.{MSH:MessageType.TriggerEvent}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().subject().patient().id().item().extension}' property='target.{PID:PatientID.IDNumber}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location2().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:PriorPatientLocation.Room}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location2().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:PriorPatientLocation.Bed}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location2().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:PriorPatientLocation.Facility}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location2().serviceDeliveryLocation().location.name},"//s:item/s:part/@value")' property='target.{PV1:PriorPatientLocation.Floor}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location1().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Room}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location1().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Bed}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location1().serviceDeliveryLocation().location.locatedEntityHasParts().locatedPlace().name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Facility}' action='set' />
<assign value='##class(HCC.Utils.Functions).GetDataByXPath(source.{controlActProcess().subject().encounterEvent().location1().serviceDeliveryLocation().location.name},"//s:item/s:part/@value")' property='target.{PV1:AssignedPatientLocation.Floor}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().location1().time().low.value}' property='target.{PV1:AdmitDateTime.Time}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().location2().time().low.value}' property='target.{PV1:DischargeDateTime(1).Time}' action='set' />
<assign value='source.{controlActProcess().subject().encounterEvent().id().item().extension}' property='target.{PID:AlternatePatientIDPID(1).IDNumber}' action='set' />
</transform>
}

}
